package poi;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Test;

public class testPOIDemo {
	@Test
	public void HSSF() throws IOException{
		Workbook wb = new HSSFWorkbook();
		Sheet sheet = wb.createSheet();
		Row nRow = sheet.createRow(7);			//第八行
		Cell nCell = nRow.createCell(4);		//第五列
		
		nCell.setCellValue("传智播客万年长！");
		File file=new File("d:/testpoi.xlsx");
		file.createNewFile();
		OutputStream os = new FileOutputStream("file");	//excel 2003
		wb.write(os);
		
		os.flush();
		os.close();
	}
	@Test
	public void HSSFtt() throws IOException{
		String path=null;
		path="D:\\test2.xlsx";
		Workbook wb = new HSSFWorkbook();
		Sheet sheet = wb.createSheet();
		Row nRow = sheet.createRow(7);			//第八行
		Cell nCell = nRow.createCell(4);		//第五列
		
		nCell.setCellValue("传智播客万年长！");
		File file=new File(path);
		file.createNewFile();
		OutputStream os = new FileOutputStream(file);	//excel 2003
		wb.write(os);
		
		os.flush();
		os.close();
	}
	
}